# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Luis Aranguren <pizzaman@hotmail.com>

_pyname=noiseprotocol
pkgname=python-noiseprotocol
pkgver=0.3.1
pkgrel=1
pkgdesc='A Python implementation of Noise Protocol Framework'
arch=(any)
url="https://github.com/plizonczyk/$_pyname"
license=(MIT)
depends=(python
         python-cryptography)
makedepends=(python-{build,installer,wheel}
             python-pypandoc
             python-setuptools)
checkdepends=(python-pytest
              python-pytest-aiohttp
              python-pytest-asyncio)
_archive="$_pyname-$pkgver"
source=("$url/archive/v$pkgver/$_archive.tar.gz")
sha256sums=('e3ac8ed99ceb929b03de9589355a2d20e9e44c74242384e38bb5a1699a351bd2')

prepare() {
	cd "$_archive"
	sed -i -E "s/ImportError/ImportError,AttributeError/" setup.py
}

build() {
	cd "$_archive"
	python -m build -wn
}

check(){
	cd "$_archive"
	local _pyver=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
	export PYTHONPATH="$PWD/lib.linux-$CARCH-cpython-$_pyver"
	python -m pytest tests
}

package() {
	cd "$_archive"
	python -m installer -d "$pkgdir" dist/*.whl
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
